#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QMenuBar* menubar = this->menuBar();
    this->setMenuBar(menubar);
    QMenu* menu1 = new QMenu("文件");
    menubar->addMenu(menu1);
    QToolBar* toolbar = new QToolBar();
    this->addToolBar(toolbar);
    QAction* action1 = new QAction("保存");
    QAction* action2 = new QAction("打开");
    action1->setToolTip("保存这个文件");
    action2->setToolTip("打开一个文件");
    toolbar->addAction(action1);
    toolbar->addAction(action2);
    menu1->addAction(action1);
    menu1->addAction(action2);
    action1->setIcon(QIcon(":/1.png"));
    action2->setIcon(QIcon(":/1.png"));
    connect(action1, &QAction::triggered, this, &MainWindow::handle);
    connect(action2, &QAction::triggered, this, &MainWindow::handle2);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handle()
{
    qDebug() << "保存";
}
void MainWindow::handle2()
{
    qDebug() << "打开";
}


